﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Extjs_ReGSharp.Sorting
{
	internal class SortingOrderController
	{
		#region Data Memebers

		private SortingOrder m_SortingOrder;

		#endregion

		#region Constructor

		public SortingOrderController(string sortingOrder)
		{
			if (!Enum.TryParse<SortingOrder>(sortingOrder, true, out m_SortingOrder))
			{
				m_SortingOrder = SortingOrder.Default;
			}
		}

		#endregion

		#region Public Methods

		public int ModifyResultByOrder(int ascendingResult)
		{
			int orderedResult = ascendingResult * (m_SortingOrder == SortingOrder.Desc ? -1 : 1);

			return orderedResult;
		}

		#endregion
	}
}
